package com.shell.governor.modules.controller;

import com.shell.bee.base.annotation.Logging;
import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.entity.mvc.RetMsg;
import com.shell.bee.persistence.model.PageLimit;
import com.shell.governor.modules.po.PubApplication;
import com.shell.governor.modules.service.PubApplicationService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PubApplicationController {
	@Autowired
	private PubApplicationService pubApplicationService;

	@RequestMapping
	@Logging(module = "��������", methods = "������������")
	public List<PubApplication> selectApplication(PageLimit limit, PubApplication application) {
		return this.pubApplicationService.getApplicationByPage(limit, application);
	}

	@RequestMapping
	@Logging(module = "��������", methods = "������������")
	public RetMsg deleteApplication(PubApplication application) {
		return this.pubApplicationService.deletePubApplication(application);
	}

	@RequestMapping
	@Logging(module = "��������", methods = "������������������")
	public RetMsg saveOrUpdateApplication(PubApplication application) {
		return this.pubApplicationService.saveOrUpdatepubApplication(application);
	}

	@RequestMapping
	@Logging(module = "��������", methods = "������������")
	public RetMsg updateApplicationStatus(PubApplication application) {
		return this.pubApplicationService.updatePubApplicationStatus(application);
	}

	@RequestMapping
	@Logging(module = "��������", methods = "����������������")
	public List<PubApplication> getApplication(PubApplication application) {
		return this.pubApplicationService.getApplication(application);
	}

	@RequestMapping
	@Logging(module = "��������", methods = "������������")
	public List<PubApplication> electApplication(PubApplication application) {
		return this.pubApplicationService.getApplicationName(application);
	}

	@RequestMapping
	@Logging(module = "��������", methods = "������������������")
	public RetMsg checkApplicationCode(String appCode) {
		if (StringUtil.emptyAndNull(appCode)) {
			return new RetMsg("warning", false, "������������");
		}
		PubApplication app = this.pubApplicationService.selectApplicationbyCode(appCode);
		if (app == null) {
			return new RetMsg("info", false, "��������");
		}
		return new RetMsg("success", false, "��������������");
	}
}
